package com.ruoyi.quartz.task;

import com.ruoyi.system.domain.HmzItem;
import com.ruoyi.system.domain.HmzMoneyInfo;
import com.ruoyi.system.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.List;

/**
 * 定时任务调度测试
 *
 * @author ruoyi
 */
@Component("ryTask")
public class RyTask
{

    //    员工操作类
    @Autowired
    private IHmzEmployeeInfoService hmzEmployeeInfoService;
    //    领用单子表操作类

    //    托盘操作类
    @Autowired
    private IHmzItemService hmzItemService;
    @Autowired
    private IHmzMoneyInfoService hmzMoneyInfoService;

    public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)
    {
        System.out.println(StringUtils.format("执行多参方法： 字符串类型{}，布尔类型{}，长整型{}，浮点型{}，整形{}", s, b, l, d, i));
    }

    public void ryParams(String params)
    {
        System.out.println("执行有参方法：" + params);
    }

    public void ryNoParams()
    {
        System.out.println("执行无参方法");
    }

    public void updateBalance(){
        List<HmzItem> hmzItems = hmzItemService.selectHmzItemListNew();
        BigDecimal bigDecimal = hmzEmployeeInfoService.selectPrice();
        if( hmzItems !=null && hmzItems.size()>0){
            for (HmzItem hmzItem : hmzItems) {
                int i = hmzEmployeeInfoService.updateBalanceNew(hmzItem.getEmployeeId(), bigDecimal);
                HmzMoneyInfo hmzMoneyInfo =new HmzMoneyInfo();
                hmzMoneyInfo.setMoney(bigDecimal);
                hmzMoneyInfo.setEmployeeId(hmzItem.getEmployeeId());
                hmzMoneyInfo.setItemNumber(1L);
                hmzMoneyInfo.setPrice(bigDecimal);
                hmzMoneyInfoService.insertHmzMoneyInfo(hmzMoneyInfo);
            }
        }
    }
}
